<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 注意源码我是做了修改的，在源码的最后一行，你可以顺着下面这个目录看下 -->
    <script src="../0_assets/js/mustache.min.js"></script>
</head>

<body>
    <ul class="list">
        <!-- 常用的写法是写在script标签里，type设置为text/html或者text/template，利用了script默认不渲染到页面的特点，然后再下面的script中利用querySelector()获取到这个标签里的innerHTML，从而直接实现渲染。就不用我们再写模板字符串了 -->
        <script type="text/template" id="templateStr">
            {{#arr}}
                <li>
                    <h3>姓名: {{name}}</h3>
                    <div>年龄: {{age}}</div>
                    <div>性别: {{sex}}</div>
                </li>
            {{/arr}}   
        </script>
    </ul>

    <script>
        let list = document.querySelector('.list');
        let templateStr = document.querySelector('#templateStr').innerHTML;
        let arr = [{
                name: 'mikaisa1',
                age: 18,
                sex: '男'
            },
            {
                name: 'mikaisa2',
                age: 19,
                sex: '男'
            },
            {
                name: 'mikaisa3',
                age: 20,
                sex: '男'
            },
        ];

        let data = {
            arr
        }

        list.innerHTML = mustache.render(templateStr, data)
        console.log(mustache.render(templateStr, data));
    </script>
</body>

</html>